import { AxiosPromise } from "axios"
import { getUrlPrefix, Request } from '../request'

//--------------------      图片上传下载    ---------------------------
export const fileUpload = (file: any): AxiosPromise<any> => {
    const formData = new FormData()
    formData.append('file', file)
    return Request.getReq(1)({
        url: '/nmvcapp/fileupload/upload',
        method: 'post',
        data: formData
    })
}

export const getImgUrl = (path: string) => {
    if (!path) return ''
    return getUrlPrefix() + '/admin/fileupload/download?filepath=' + path
}

export const getImgUrlPath = (path: string) => {
    if (!path) return ''
    // @ts-ignore
    return process.env.VITE_API_URL + '/admin/fileupload/download?filepath=' + path
}
